package com.hjq.toast.demo;

import android.content.Intent;
import android.os.Build;
import android.os.Bundle;
import android.util.TypedValue;
import android.view.Gravity;
import android.view.View;

import androidx.appcompat.app.AppCompatActivity;

import com.google.android.material.snackbar.Snackbar;
import com.hjq.toast.ToastClient;
import com.hjq.toast.style.BlackToastStyle;
import com.hjq.toast.style.WhiteToastStyle;


/**
 * author :
 * github : https://github.com/getActivity/ToastUtils
 * time   : 2018/09/01
 * desc   : ToastUtils 使用案例
 */
public final class ToastActivity extends AppCompatActivity {
    private int mMa=0;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_toast);
    }

    public void show1(View v) {
        mMa=mMa+1;
        ToastClient.getClient()
                .setDefaultGravity()
                .show("我是普通的 Toast  "+mMa);
    }

    @SuppressWarnings("AlibabaAvoidManuallyCreateThread")
    public void show2(View v) {
        new Thread(new Runnable() {

            @Override
            public void run() {
                ToastClient.getClient()
                        .setDefaultGravity()
                        .show("我是子线程中弹出的吐司");
            }
        }).start();
    }

    public void show3(View v) {
        ToastClient.getClient()
                .setStyle(new WhiteToastStyle())
                .show("动态切换白色吐司样式成功");
    }

    public void show4(View v) {
        ToastClient.getClient()
                .setStyle(new BlackToastStyle())
                .show("动态切换黑色吐司样式成功");
    }

    public void show5(View v) {
        ToastClient.getClient()
                .setView(R.layout.toast_custom_view)
                .setGravity(Gravity.CENTER)
                .show("自定义 Toast 布局");
    }




}